<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script type="text/javascript">
			function func(mm) {

				var obj = JSON.parse('{ "name":"'+mm+'", "alexa":10000, "site":"www.runoob.com" }');
				
				//var obj = eval({ "name":"runoob", "alexa":10000, "site":"www.runoob.com" });
				//var obj='{ "name":mm, "alexa":10000, "site":"www.runoob.com" }';
				var d = document.getElementById("div1");
				var d2 = document.getElementById("div2");
				var myJSON = JSON.stringify(obj);
				d.innerHTML = obj.name;
				d2.innerHTML =myJSON;
			}
		</script>
		<button onclick="func('xh')">按一下</button>
		<div id=div1></div>
			<div id=div2></div>
	</body>

</html>